<?php


namespace app\backend\controller;
use app\common\RootController;
use app\common\service\UploadService;

class Upload extends Backend
{
    /**
     * 上传图片
     * @param UploadService $service
     * @return \think\response\Json
     */
    public function image(UploadService $service)
    {
        $imageResult = $service->image($this->request->file());
        return $this->success($imageResult);
    }

    /**
     * 编辑器文件上传
     * @param UploadService $service
     * @return \think\response\Json
     */
    public function tinymce(UploadService $service)
    {
        $imageResult = $service->tinymce($this->request->file());
        return json($imageResult);
    }

    /**
     * 文件上传
     * @param UploadService $service
     * @return \think\response\Json
     */
    public function file(UploadService $service)
    {
        $fileResult = $service->file($this->request->file());
        return $this->success($fileResult);
    }

    /**
     * 图片预览
     * @return string
     */
    public function preview()
    {
        return $this->fetch();
    }
}